package view
{
	import com.common.utils.Reflection;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.TimerEvent;
	import flash.text.TextField;
	import flash.utils.Timer;

	/**
	 *加载进度条 
	 * @author lxh
	 * 
	 */	
	public class LoadingView extends Sprite
	{
		private var _symbol :MovieClip;
		/**
		 *百分比 
		 */		
		private var txtProgress :TextField;///
		/**
		 *进度mc 
		 */		
		private var loadBar_mc :MovieClip;
		
		public var totalBytes :int;//总字节数
		
		private var _loadedBytes :int;//已下载字节数
		/**
		 *加载提示 
		 */		
		private var txtContent :TextField;
		
		private var _content :String;
		/**
		 *光 
		 */		
		private var lightMc :MovieClip;
		/**
		 *遮罩 
		 */		
		private var maskSp	 :MovieClip;
		
		public function LoadingView()
		{
			super();
			initView();
		}
		
		public function set content(value :String):void
		{
			_content = value;
			txtContent.text = value;
		}
		
		public function get content():String
		{
			return _content;
		}
		
		private function initView():void
		{
			_symbol = Reflection.createInstance("MainLoaderUI");
			this.addChild(_symbol);
			loadBar_mc = _symbol.progressMC;
			txtContent = _symbol.txtContent;
			txtProgress = _symbol.txtProgress;
			lightMc = _symbol.lightMc;
			maskSp = _symbol.maskSp;
			loadBar_mc.mask = maskSp;
		}
		
		public function set loadedBytes(value :int):void
		{
			_loadedBytes = value;
			var loadedPercent :int = (_loadedBytes / totalBytes) * 100;
			//var frame :int = loadedPercent * loadBar_mc.totalFrames / 100;
			//trace("persent = ",loadedPercent,"%",",frame = ",frame);
			//loadBar_mc.gotoAndStop(frame);
			maskSp.width = loadedPercent / 100 * loadBar_mc.width;
			lightMc.x = maskSp.x + maskSp.width - 10;
			//trace(lightMc.x,maskSp.width);
			txtProgress.text = loadedPercent + "%";
		}
		
		public function get loadedBytes():int
		{
			return _loadedBytes;
		}
	}
}